package com.demo.yuanzi.service.impl;

import com.demo.yuanzi.entity.YuanziSaPermission;
import com.demo.yuanzi.dao.YuanziSaPermissionDao;
import com.demo.yuanzi.service.YuanziSaPermissionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (YuanziSaPermission)表服务实现类
 *
 * @author makejava
 * @since 2024-05-09 14:16:56
 */
@Service("yuanziSaPermissionService")
public class YuanziSaPermissionServiceImpl implements YuanziSaPermissionService {
    @Resource
    private YuanziSaPermissionDao yuanziSaPermissionDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public YuanziSaPermission queryById(Integer id) {
        return this.yuanziSaPermissionDao.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param yuanziSaPermission 实例对象
     * @return 实例对象
     */
    @Override
    public YuanziSaPermission insert(YuanziSaPermission yuanziSaPermission) {
        this.yuanziSaPermissionDao.insert(yuanziSaPermission);
        return yuanziSaPermission;
    }

    /**
     * 修改数据
     *
     * @param yuanziSaPermission 实例对象
     * @return 实例对象
     */
    @Override
    public YuanziSaPermission update(YuanziSaPermission yuanziSaPermission) {
        this.yuanziSaPermissionDao.update(yuanziSaPermission);
        return this.queryById(yuanziSaPermission.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.yuanziSaPermissionDao.deleteById(id) > 0;
    }
}
